package com.wn.equipment.service.imp;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.EquipmentManagement;
import com.wn.equipment.mapper.EquipmentManagementMapper;
import com.wn.equipment.service.EquipmentManagementService;
import com.wn.equipment.vo.EquipmentVo;
import com.wn.utils.PageBeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @author zhairenhao
 * @date 2022/10/21 15:14
 * @description
 */
@Service
@Slf4j
public class EquipmentManagementServiceImp implements EquipmentManagementService {
    @Autowired
    EquipmentManagementMapper equipmentManagementMapper;

    @Override
    public void delete(int id) {
        equipmentManagementMapper.delete(id);
    }

    @Override
    public EquipmentManagement getById(int id) {
        return equipmentManagementMapper.getById(id);
    }

    @Override
    public void update(EquipmentManagement equipmentManagement) {
        equipmentManagementMapper.update(equipmentManagement);
    }

    @Override
    public void insert(EquipmentManagement equipmentManagement) {
        equipmentManagement.setStatus("y");
        equipmentManagementMapper.insert(equipmentManagement);
    }

    /**
     * @return java.util.List<com.wn.entity.EquipmentManagement>
     * @Author ReenHamZ
     * @Description //TODO
     * @Param []
     **/
    @Override
    public List<EquipmentManagement> getAll() {
        return equipmentManagementMapper.getAll();
    }

    /**
     * @return java.util.List<com.wn.entity.EquipmentManagement>
     * @Author ReenHamZ
     * @Description //TODO
     * @Param [com.wn.entity.EquipmentManagement]
     **/
    @Override
    public List<EquipmentManagement> getByCondition(EquipmentManagement equipmentManagement) {
        return equipmentManagementMapper.getByCondition(equipmentManagement);
    }

    /**
     * @return java.util.List<com.wn.entity.EquipmentManagement>
     * @Author ReenHamZ
     * @Description //TODO
     * @Param [com.wn.entity.EquipmentManagement]
     **/
    @Override
    public PageBean<EquipmentManagement> getEquipmentByPages(EquipmentVo equipmentVo) {
        Page<EquipmentManagement> page = PageHelper.startPage(equipmentVo.getCurrPage(), equipmentVo.getPageSize());
        List<EquipmentManagement> list = equipmentManagementMapper.getByCondition(equipmentVo.getEquipmentManagement());
        PageBean<EquipmentManagement> pageBean = PageBeanUtil.getPageBean(list, page, equipmentVo.getCurrPage(), equipmentVo.getPageSize());
        return pageBean;
    }
}
